package CS4310.csueb.characters;
import java.util.ArrayList;

import CS4310.csueb.items.Armor;
import CS4310.csueb.items.Food;
import CS4310.csueb.items.Item;
import CS4310.csueb.items.KeyItem;
import CS4310.csueb.items.Shoe;
import CS4310.csueb.items.Weapon;

/**
 * Implementation for the hero inventory. This
 * is responsible for keeping a record of all of the
 * items in the hero's possession at any given
 * time. 
 *
 * @author Levester Chaney
 *
 */
public class Inventory
{
	private ArrayList<Weapon> weapons;
	private ArrayList<Armor> armor;
	private ArrayList<Shoe> shoes;
	private ArrayList<Food> food;
	private ArrayList<KeyItem> keyItems;
	
	public Inventory()
	{
		weapons = new ArrayList<Weapon>();
		armor = new ArrayList<Armor>();
		shoes = new ArrayList<Shoe>();
		food = new ArrayList<Food>();
		keyItems = new ArrayList<KeyItem>();
	}
	
	//Add items to inventory. It checks the type of the item
	//(Weapon, Shoe, etc) and adds to appropriate ArrayList.
	public void addItem (Item i) {
		//duplicate items cannot be added to list. Will implement checking soon -Bikas
		if(i instanceof Weapon) {
			weapons.add((Weapon) i);
		}
		else if(i instanceof Armor) {
			armor.add((Armor) i);
		}
		else if(i instanceof Shoe) {
			shoes.add((Shoe) i);
		}
		else if (i instanceof Food) {
			food.add((Food) i);
		}
		else  keyItems.add((KeyItem) i);
	}
	
	/**
	 * Retrieves the list of weapons that the hero
	 * has at his disposal.
	 * @return the list of weapons
	 */
	public ArrayList<Weapon> getWeaponsList()
	{
		return this.weapons;
	}
	
	/**
	 * Retrieves the list of armor that the hero
	 * has at his disposal.
	 * @return the list of armor
	 */
	public ArrayList<Armor> getArmorList()
	{
		return this.armor;
	}
	
	/**
	 * Retrieves the list of shoes that the hero
	 * has at his disposal.
	 * @return the list of shoes
	 */
	public ArrayList<Shoe> getShoeList()
	{
		return this.shoes;
	}
	
	/**
	 * Retrieves the list of food that the hero
	 * has at his disposal.
	 * @return the list of food
	 */
	public ArrayList<Food> getFoodList()
	{
		return this.food;
	}
	
	/**
	 * Retrieves the list of key items that the hero
	 * is in possession of
	 * @return the list of key items
	 */
	public ArrayList<KeyItem> getKeyItemList()
	{
		return this.keyItems;
	}
	
	/**
	 * Retrieves a key item from the inventory to be 
	 * handed over for the forward motion of the game.
	 * @param name the name of the key item to retrieve.
	 * @return the key item to be handed over
	 */
	public KeyItem getKeyItem(String name)
	{
		KeyItem item = null;;
		
		for(KeyItem k : keyItems)
		{
			if(k.toString().equals(name))
				item = k;
		}
		return item;
	}
}
